//触发进度条事件
function Progress() {
    $("#progress_win").modal("show")
    let pg = document.getElementById('pg')
    let pgv = document.getElementById('pgv')
    let timer = setInterval(function () {
        setTimeout(function () {
            if (pg.value !== 100) {
                pg.value++
                pgv.innerHTML = '进度：' + pg.value + '%'
            } else {
                pgv.innerHTML = '融合完成'
                clearInterval(timer)
            }
        }, 1000)
    }, 100)
}

//部分数据融合
//通话记录融合
function Partdata_mix() {
    let call = document.getElementById('call');
    let call_num = document.getElementById('call_num');
    let call_sum = document.getElementById('call_sum');
    let tonghua = document.getElementById('tonghua');
    let tonghua_num = document.getElementById('tonghua_num');
    let tonghua_sum = document.getElementById('tonghua_sum');
    let message = document.getElementById('message');
    let message_num = document.getElementById('message_num');
    let message_sum = document.getElementById('message_sum');
    let keyword = document.getElementById('keyword');
    let keyword_num = document.getElementById('keyword_num');
    let keyword_sum = document.getElementById('keyword_sum');
    let chengwei = document.getElementById('chengwei');
    let chengwei_num = document.getElementById('chengwei_num');
    let chengwei_sum = document.getElementById('chengwei_sum');
    let phone = $("input[name='Add_mix_num']").val();
    if (phone === 0) {
        phone = "13020003445";
    }
    let request_parameters = {type: "data_fusion", phone_num: phone};
    let optionJson = [];

    call.innerHTML = '通话记录融合进度：' + 0 + '%';
    call_num.value = 0;
    tonghua.innerHTML = '通话时间段提取进度：' + 0 + '%';
    tonghua_num.value = 0;
    message.innerHTML = '短信记录融合进度：' + 0 + '%';
    message_num.value = 0;
    keyword.innerHTML = '关键词提取进度：' + 0 + '%';
    keyword_num.value = 0;


    // if(phone == 0){
    //     alert("请输入手机号码");
    // }
    //else{
    $.ajax({
        type: "post",
        url: "http://127.0.0.1:9998/preprocessed/data_fusion",
        data: request_parameters,
        async: false,
        success: function (data_fusion) {
            console.log(data_fusion);
            optionJson = data_fusion.data;
            let timer1 = setInterval(function () {
                setTimeout(function () {
                    if (call_num.value !== 100) {
                        call_num.value++
                        call.innerHTML = '通话记录融合进度：' + call_num.value + '%'
                    } else {
                        call.innerHTML = '通话记录融合完成'
                        call_sum.innerHTML = '通话记录共' + optionJson.call_num + '条'
                        clearInterval(timer1)
                    }
                }, 500)
            }, 10)
            let timer5 = setInterval(function () {
                setTimeout(function () {
                    if (tonghua_num.value !== 100) {
                        tonghua_num.value++
                        tonghua.innerHTML = '通话时间段提取进度：' + call_num.value + '%'
                    } else {
                        tonghua.innerHTML = '通话时间段提取完成'
                        tonghua_sum.innerHTML = '通话时间段共' + optionJson.contact_time_num + '条'
                        clearInterval(timer5)
                    }
                }, 500)
            }, 10)
            let timer2 = setInterval(function () {
                setTimeout(function () {
                    if (message_num.value !== 100) {
                        message_num.value++
                        message.innerHTML = '短信记录融合进度：' + message_num.value + '%'
                    } else {
                        message.innerHTML = '短信记录融合完成'
                        message_sum.innerHTML = '短信记录共' + optionJson.message_num + '条'
                        clearInterval(timer2)
                    }
                }, 1000)
            }, 10)
            let timer3 = setInterval(function () {
                setTimeout(function () {
                    if (keyword_num.value !== 100) {
                        keyword_num.value++
                        keyword.innerHTML = '关键词提取进度：' + keyword_num.value + '%'
                    } else {
                        keyword.innerHTML = '关键词提取完成'
                        keyword_sum.innerHTML = '提取关键词共15个'
                        clearInterval(timer3)
                    }
                }, 500)
            }, 20)
            // let timer4 = setInterval(function () {
            //     setTimeout(function () {
            //         if (chengwei_num.value !== 100) {
            //             chengwei_num.value++
            //             chengwei.innerHTML = '称谓词提取进度：' + chengwei_num.value + '%'
            //         } else {
            //             chengwei.innerHTML = '称谓词提取完成'
            //             chengwei_sum.innerHTML='提取称谓词共3个'
            //             clearInterval(timer4)
            //         }
            //     },500)
            // }, 20)
        }
    });
    //}
}